<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>Document</title>
	<style type="text/css">
       #box{
       margin: 0 auto;
       width:600px;
       }
	</style>
	<script type="text/javascript">
		window.onload = function(){
           var Obtn = document.getElementById("btn");
           Obtn.onclick = function() {
           	var OVa = document.getElementById("value");
           	//取到字符串和数组
           	var StrArr = OVa.value.split(",");
           	var totalNum = 0;
           	for (var i =0; i < StrArr.length; i++) {
           		totalNum += parseInt(StrArr[i]);
           	}
           	alert(totalNum)
           }
		}
	</script>
</head>
<body>
<div id="box">
	<label><input type="text" value="1,2,3,4,5,6" id="value"></input></label>

	<p id="btn"><button>求和</button></p>
</div>
</body>
</html>